<?php
// +----------------------------------------------------------------------
// | Author: 黄泽宏 <2623213969@qq.com>
// +----------------------------------------------------------------------

namespace app\home\controller;
/**
 * 公告控制器
 */
class NoticeController extends HomeController {
    public function _initialize() {
        parent::_initialize();
    }

    /**
     *公告列表
     */
    public function index(){
        $notice_list = db('article')->where(array('cate_id'=>10))->select();
        $this->assign("notice_list",$notice_list);
        return $this->fetch('index');
    }
    
   /**
     *公告详情
     */
    public function details(){
        $id = input('id',0);
        $notice = db('article')->where(array("id"=>$id,'cate_id'=>10))->find();
        $notice['content'] = htmlspecialchars_decode($notice['content']);
        $this->assign("notice",$notice);
        return $this->fetch('details');
    }
    
    /**
     * 在线反馈
     */
    public function feedback(){
        return $this->fetch('feedback');
    }
    
     /**
     * 在线反馈文章 【ajax】
     */
    public function ajax_feedback(){
        $id = input('param.id');
        $detail_html = "";
         $article_list = db('article')->where(array('cate_id'=>$id))->select();
          $detail_tmpl =  '<div class="order_list"></div>
                          <div class="feedbackone">
                               <h3><span>%s</span> <div class="feedbackone_img"><img src="../../../../../Public/home/images/xia.png" alt="" width="100%%"></div></h3>
                                <div class="feebbackhide">
                                  %s
                                </div>
                          </div>';
          foreach ($article_list as $article){
               $detail_html .=sprintf($detail_tmpl,
                       $article['title'],
                       htmlspecialchars_decode($article['content'])
                       );
          }

       $this->success($detail_html);
    }
    
   /**
     * 在线反馈评论 【ajax】
     */ 
   public function feedback_comment(){
       if(IS_POST){
           $comment = input('param.comment');
           if($comment==""){
               $this->error("评论不允许为空！");
           }
           $data = array(
               "user_id"=>  $this->user_id,
               "content"=>$comment,
               "addtime"=>  time()
           );
          if(db('feedback_comment')->insert($data)){
              $this->success("评论成功！");
          } 
          
       }
   }
    
    
    
    
  

}